package com.clc.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.clc.bean.TestLog;
import com.clc.controller.TestLogController;
import com.clc.dao.ITestLogDao;
import com.clc.service.ITestLogService;


@Component("testLogService")
public class TestLogServiceImpl implements ITestLogService {
	private static final Log log = LogFactory.getLog(TestLogServiceImpl.class);
	@Autowired
	private ITestLogDao testLogDao;
	@Override
	public void saveLog(TestLog testLog) throws Exception {
		testLogDao.saveTestLog(testLog);
	}
	@Override
	public void saveBatchLog() throws Exception {
		List<TestLog> list = new ArrayList<TestLog>();
		for(int i=0;i<50000;i++){
			TestLog log = new TestLog(2,100);
			list.add(log);
		}
		long s = System.currentTimeMillis();
		log.info("开始时间"+s);
		testLogDao.saveBatch(list);
		long e = System.currentTimeMillis();
		log.info("结束时间"+e);
		log.info("批量插入"+list.size()+"条数据,共耗时:"+((e-s)/1000)+"秒");
	}

}
